package com.eco.fanliapp.job.goodsjob;

import com.eco.fanliapp.service.IAppGoodsService;
import com.eco.fanliapp.service.ISyUserTaskService;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;

/**
 * @date 2019-12-01
 */
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class SqjdUserMoneyLogTask implements Job, Serializable {
    @Autowired
    private ISyUserTaskService syUserTaskService;
    private static final Logger log = LoggerFactory.getLogger(SqjdUserMoneyLogTask.class);

    public SqjdUserMoneyLogTask() {
    }

    @Override
    public void execute(JobExecutionContext context) {

        //取得job详情
        JobDetail jobDetail = context.getJobDetail();

        JobDataMap dataMap = jobDetail.getJobDataMap();

        int executeCount = 0;
        if (dataMap.containsKey("runCount")) {
            executeCount = dataMap.getInt("runCount");
        }

        // 增量计数并将其存储回 JobDataMap，这样可以适当保持工作状态
        executeCount++;
        dataMap.put("runCount", executeCount);

        long startTime = System.currentTimeMillis();
        log.info("***************************************开始执行添加日志定时扫描任务-GoodsFreeTask：executeCount=" + executeCount + "--startTime=" + startTime);
        syUserTaskService.sqjdAddMoneyLog();


        long endTime = System.currentTimeMillis();
        log.info("***************************************结束执行添加日志定时扫描任务-GoodsFreeTask：executeCount=" + executeCount + "--endTime=" + endTime + "--耗时=" + (endTime - startTime));

    }
}
